473,425 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Radio Buttons in Menu

How can I put a set of Radio Buttons in a Menu? A bullet list of items where
selecting one automatically unselects the others.

Thanks
Apr 7 '06 #1
7 8700
Hi,

This functionality is not automatic. (Assuming you are referring to VS
2003, .NET 1.1)

Might be many ways to do it. Manually or Cleverly...

Here's my way : (The manual way)

--------------------------------------------

// This method is wired to Click events of all the MenuItems.
private void AllMnus_Click(object sender, System.EventArgs e)
{
MenuItem mnu = (MenuItem)sender;
Checker(mnu);
switch (mnu.Text)
{
case "One":
// Do your stuff
break;
case "Two":
// Do double the stuff
break;
case "Three":
// Do double the stuff
break;
}
}

// Iterates through the MenuItems, first unchecking all of them, and
then checking
// the relevant one.
private void Checker(MenuItem mnu)
{
foreach (MenuItem eachMnu in mnuTest.MenuItems)
{
eachMnu.Checked = false;
}
mnu.Checked = true;
}

--------------------------------------------

Explanation : Since the MenuItems have no Tag property (and
surprisingly, no Name property as well), we have to check the Text
property to find out which one was clicked. Then we just uncheck all of
them and check the proper one.

The Clever way :
An excellent alternative to doing it manually, might be to use Mick
Doherty's implementation. He uses an Extender component to add a Tag
property to MenuItems, and also a RadioGroup property which
accomplishes what we need. He should call it "Killing two birds with
one stone !" ;-)

This latter is the method I would recommend to you. Check out
<http://www.dotnetrix.pwp.blueyonder.co.uk/menus.html>

Regards,

Cerebrus.

Apr 8 '06 #2
You can use Checked menus..and use code to do the check/uncheck. Why radio
buttons? any reason?

VJ

"Martijn Mulder" <i@m> wrote in message
news:44***********************@news.wanadoo.nl...
How can I put a set of Radio Buttons in a Menu? A bullet list of items
where selecting one automatically unselects the others.

Thanks

Apr 8 '06 #3
I think Martijn means a RadioCheck style of Checked Menus. Not a Radio
button control. Atleast, that's what I assumed.

Regards,

Cerebrus.

Apr 8 '06 #4
>I think Martijn means a RadioCheck style of Checked Menus. Not a Radio
button control. Atleast, that's what I assumed.

Radio Buttons

A radio button looks very much like a check box except that it is shaped
like a circle rather than a box. A heavy dot within the circle indicates
that the radio button has been checked. The radio button has the window
style BS_RADIOBUTTON or BS_AUTORADIOBUTTON (...). groups of radio buttons
are conventionally used to indicate mutually exclusive options. Unlike check
boxes, radio buttons do not work as toggles - that is, when you click a
radio button a second time, its state remains unchanged. (Petzold,
Programming Windows 95)

I want to have a dropdown menu from the main menu filled with radio buttons,
like this:

File Edit View Options
o Black/White
o Color
o Sepia
o Acid

with one of the options on and all other options off until clicked.
Apr 8 '06 #5
Hi,

Did you see my response to your original post ?? It still sounds like
that's what you need.

Regards,

Cerebrus.

Apr 8 '06 #6
> Did you see my response to your original post ?? It still sounds like
that's what you need.


I am afraid you are right (thank you!). It's just that I expected it to be
build into C# and that it was only naming confusion that stopped me from
finding it. The System.Windows.Forms.ToolStripMenuItem does have a way to
set CheckBoxes on them, the square boxes that you can click on/of. The
Radiostyle that I need is not supported? mhhh...
Apr 8 '06 #7
Then the difference is not in language, but in the version of VS. I'm
still at VS 2003.

Apr 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: elhombrebala | last post by:
With this script I can force the user to select the checkbox befor continuing, but now I have a menu with lots of radio unputs and I woul like the user to select at least 2 of them; how can I check...
1
by: Rick | last post by:
After being frustrated with this issue on several occasions I think I found the secret sauce for solving the issue after reading a few different messages about what others thought and trying a...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
3
by: TORQUE | last post by:
Hi How can I make a radio button create an action like enabling or disabling a delete button in a form? TIA TORQUE
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
2
by: Kusank | last post by:
I have 8 radio buttons that when they are selected will cause the drop down menu to change so that the sizes in the menu are correct, this works prefectly fine. But the issue I am having is once the...
4
by: RBrowning1958 | last post by:
Hello, Is there a way to group menu items so they act like radio buttons - that is when one is checked the others in the same group are unchecked - I'm looking for a property to group menu items...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.